#include <callback_interface.hpp>
int CallbackInterface::event_auth_password_function(ssh_session session, const char *user, const char *password, void *userdata){
    return SSH_ERROR;
}

ssh_channel CallbackInterface::event_channel_open_request_session_function(ssh_session session, void *userdata){
    return nullptr;
}

int CallbackInterface::event_auth_pubkey(ssh_session session, const char *user, struct ssh_key_struct *pubkey, char signature_state, void *userdata){
        const char *authorizedkeys = SSHConfig::getConfig()->get(SSH_AUTH_FILE).c_str();
    if (authorizedkeys[0])
    {
        ssh_key key = nullptr;
        int result;
        struct stat buf;
        if (stat(authorizedkeys, &buf) == 0)
        {
            result = ssh_pki_import_pubkey_file(authorizedkeys, &key);
            if ((result != SSH_OK) || (key == nullptr))
            {
                logger_info("Unable to import public key file");
            }
            else
            {
                result = ssh_key_cmp(key, pubkey, SSH_KEY_CMP_PUBLIC);
                ssh_key_free(key);
                if (result == 0)
                {
                    return SSH_AUTH_SUCCESS;
                }
            }
        }
    }
    return SSH_AUTH_DENIED;
}

// 客户端回调
int CallbackInterface::event_channel_data_callback(ssh_session session, ssh_channel channel, void *data, uint32_t len, int is_stderr, void *userdata){
    return SSH_ERROR;
}

int CallbackInterface::event_channel_exec_request_callback(ssh_session session, ssh_channel channel, const char *command, void *userdata){
    return SSH_ERROR;
}
int CallbackInterface::event_channel_pty_request_callback(ssh_session session, ssh_channel channel, const char *term, int width, 
               int height, int pxwidth, int pwheight, void *userdata){
    return SSH_ERROR;
               }
int CallbackInterface::event_channel_pty_window_change_callback(ssh_session session, ssh_channel channel, int width, int height,
                    int pxwidth, int pwheight, void *userdata){
    return SSH_ERROR;
                    }
int CallbackInterface::event_channel_subsystem_request_callback(ssh_session session,ssh_channel channel,const char *subsystem,void *userdata){
    return SSH_ERROR;
}
int CallbackInterface::event_channel_shell_request_callback(ssh_session session, ssh_channel channel, void *userdata){
    return SSH_ERROR;
}